package com.itheima.demo07;

import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * @author Zhang_Han
 * @version 1.0
 * @date 2020/7/14 13:47
 */
public class Demo_001 {
    public static void main(String[] args) {
        //手动创建线程池;
        ThreadPoolExecutor tpe = new ThreadPoolExecutor(2,
                3,
                10,
                TimeUnit.SECONDS,
                new ArrayBlockingQueue<>(2),
                Executors.defaultThreadFactory(),
                new ThreadPoolExecutor.DiscardOldestPolicy());
        for (int i = 0; i < 10; i++) {
            tpe.submit(()->{
                System.out.println(Thread.currentThread().getName()+"执行了!");
            });
        }
        tpe.shutdown();
    }
}
